package com.example.smartall.diaglog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.example.smartall.R;
import com.example.smartall.adapter.ServiceRecycleAdapter;
import com.example.smartall.entity.ServiceBean;
import com.example.smartall.ui.ActActivity;
import com.example.smartall.ui.HospitalActivity;
import com.example.smartall.ui.HouseActivity;
import com.example.smartall.ui.JobHuntingActivity;
import com.example.smartall.ui.OrderActivity;
import com.example.smartall.ui.PaymentActivity;
import com.example.smartall.ui.SubwayActivity;
import com.example.smartall.ui.CarParkingActivity;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 全部服务搜索弹窗
 * 若没有数据也展示空数据
 */
public class SearchServiceDialog extends Dialog {

    private Context context;
    private RecyclerView rv;
    private List<ServiceBean.RowsBean> rowsBeans;
    private ServiceRecycleAdapter serviceRecycleAdapter;

    private Map<String,Class> params = new HashMap<>();

    public SearchServiceDialog(@NonNull Context context, List<ServiceBean.RowsBean> rowsBeans) {
        super(context);
        this.context = context;
        this.rowsBeans = rowsBeans;
    }

    public SearchServiceDialog(@NonNull Context context, int themeResId) {
        super(context, themeResId);
    }

    protected SearchServiceDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
        super(context, cancelable, cancelListener);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.service_dialog);
        rv = (RecyclerView) findViewById(R.id.rv);

        //点击跳转数据
        params.put("城市地铁", SubwayActivity.class);
        params.put("门诊预约", HospitalActivity.class);
        params.put("停哪儿", CarParkingActivity.class);
        params.put("外卖订餐", OrderActivity.class);
        params.put("生活缴费", PaymentActivity.class);
        params.put("找工作", JobHuntingActivity.class);
        params.put("找房子", HouseActivity.class);
        params.put("活动管理", ActActivity.class);

        rv.setLayoutManager(new GridLayoutManager(context, 3));
        serviceRecycleAdapter = new ServiceRecycleAdapter(context, rowsBeans);
        serviceRecycleAdapter.setParams(params);
        rv.setAdapter(serviceRecycleAdapter);
    }
}
